/*
    Churned Ajax Toolkit
    http://www.codeplex.com/ChurnedAjaxToolkit

    This source is subject to the Microsoft Permissive License.
    All other rights reserved.

    Version:  1.0.1 released 25 April 2008
*/

using System;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.ComponentModel;
using System.ComponentModel.Design;
using AjaxControlToolkit;

#region Assembly Resource Attribute
[assembly: System.Web.UI.WebResource("ChurnedAjaxToolkit.TextEdit.TextEditBehavior.js", "text/javascript")]
[assembly: System.Web.UI.WebResource("ChurnedAjaxToolkit.TextEdit.TextEdit.css", "text/css", PerformSubstitution = true)]
#endregion

namespace ChurnedAjaxToolkit {
    /// <summary>
    /// Extend a textbox to display a label when it does not have focus.
    /// </summary>
    [Designer(typeof(TextEditDesigner))]
    [ClientCssResource("ChurnedAjaxToolkit.TextEdit.TextEdit.css")]
    [ClientScriptResource("ChurnedAjaxToolkit.TextEditBehavior", "ChurnedAjaxToolkit.TextEdit.TextEditBehavior.js")]
    [TargetControlType(typeof(TextBox))]
    public class TextEditExtender : ExtenderControlBase {

        /// <summary>
        /// How the edit mode is activated.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue(TextEditActivationMode.SingleClick)]
        public TextEditActivationMode ActivationMode {
            get { return GetPropertyValue("ActivationMode", TextEditActivationMode.SingleClick); }
            set { SetPropertyValue("ActivationMode", value); }
        }

        /// <summary>
        /// The text to display when TextBox.Text is equal to String.Empty
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue("")]
        public string BlankText {
            get { return GetPropertyValue("BlankText", ""); }
            set { SetPropertyValue("BlankText", value); }
        }

        /// <summary>
        /// The name of a javascript callback function to be called when the textbox loses focus.
        /// </summary>
        [ExtenderControlEvent]
        [ClientPropertyName("clientEdited")]
        [DefaultValue("")]
        public string ClientEdited {
            get { return GetPropertyValue("ClientEdited", ""); }
            set { SetPropertyValue("ClientEdited", value); }
        }

        /// <summary>
        /// How long to delay activation when TextEditActivationMode.Hover is used.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue(TextEditHoverActivationDelay.Immediate)]
        public TextEditHoverActivationDelay HoverActivationDelay {
            get { return GetPropertyValue("HoverActivationDelay", TextEditHoverActivationDelay.Immediate); }
            set { SetPropertyValue("HoverActivationDelay", value); }
        }

        /// <summary>
        /// The css class to apply to the label.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue("")]
        public string LabelCssClass {
            get { return GetPropertyValue("LabelCssClass", ""); }
            set { SetPropertyValue("LabelCssClass", value); }
        }

        /// <summary>
        /// The css class to apply to the label during a mouse over state.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue("")]
        public string LabelHoverCssClass {
            get { return GetPropertyValue("LabelHoverCssClass", ""); }
            set { SetPropertyValue("LabelHoverCssClass", value); }
        }

        /// <summary>
        /// The tooltip text for the label.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue("")]
        public string LabelTooltipText {
            get { return GetPropertyValue("LabelTooltipText", ""); }
            set { SetPropertyValue("LabelTooltipText", value); }
        }

        /// <summary>
        /// The maximum height allowed when ResizeTextboxHeight is enabled.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue(int.MaxValue)]
        public int MaxTextboxHeight {
            get { return GetPropertyValue("MaxTextboxHeight", int.MaxValue); }
            set { SetPropertyValue("MaxTextboxHeight", value); }
        }

        /// <summary>
        /// The maximum width allowed when ResizeTextboxWidth is enabled.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue(int.MaxValue)]
        public int MaxTextboxWidth {
            get { return GetPropertyValue("MaxTextboxWidth", int.MaxValue); }
            set { SetPropertyValue("MaxTextboxWidth", value); }
        }

        /// <summary>
        /// The minimum height allowed when ResizeTextboxHeight is enabled.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue(0)]
        public int MinTextboxHeight {
            get { return GetPropertyValue("MinTextboxHeight", 0); }
            set { SetPropertyValue("MinTextboxHeight", value); }
        }

        /// <summary>
        /// The minimum width allowed when ResizeTextboxWidth is enabled.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue(0)]
        public int MinTextboxWidth {
            get { return GetPropertyValue("MinTextboxWidth", 0); }
            set { SetPropertyValue("MinTextboxWidth", value); }
        }

        /// <summary>
        /// Resize the height of the textbox to fit the height of the label.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue(true)]
        public bool ResizeTextboxHeight {
            get { return GetPropertyValue("ResizeTextboxHeight", true); }
            set { SetPropertyValue("ResizeTextboxHeight", value); }
        }

        /// <summary>
        /// Resize the width of the textbox to fit the width of the label.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue(true)]
        public bool ResizeTextboxWidth {
            get { return GetPropertyValue("ResizeTextboxWidth", true); }
            set { SetPropertyValue("ResizeTextboxWidth", value); }
        }

        /// <summary>
        /// The css class to apply to the textbox.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue("")]
        public string TextboxCssClass {
            get { return GetPropertyValue("TextboxCssClass", ""); }
            set { SetPropertyValue("TextboxCssClass", value); }
        }

        /// <summary>
        /// The tooltip text for the textbox.
        /// </summary>
        [ExtenderControlProperty]
        [DefaultValue("")]
        public string TextboxTooltipText {
            get { return GetPropertyValue("TextboxTooltipText", ""); }
            set { SetPropertyValue("TextboxTooltipText", value); }
        }

    }
}
